﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ScanManager : MonoBehaviour
{
    public string[] keywords;

    public GameObject[] results;

    public GameObject None;

    public Button btn;

    public Button Scan;

    public InputField ip;

    void Start()
    {
        Scan.onClick.AddListener(delegate
        {
            int i;
            bool Find = false;
            for (i = 0; i < keywords.Length; i++)
            {
                if (ip.text == keywords[i])
                {
                    Find = true;
                    break;
                }
            }
            if (Find)
            {
                for (int a = 0; a < results.Length; a++)
                {
                    if (a == i)
                    {
                        results[a].SetActive(true);
                        results[a].GetComponent<Animation>().Play();
                        btn.gameObject.SetActive(true);
                    }
                    else
                    {
                        results[a].SetActive(false);
                    }
                }
            }
            else
            {
                None.SetActive(true);
                None.GetComponent<Animation>().Play();
                btn.gameObject.SetActive(true);
            }

        });
        btn.onClick.AddListener(delegate
        {
            for (int a = 0; a < results.Length; a++)
            {
                results[a].SetActive(false);
            }
            None.SetActive(false);
            btn.gameObject.SetActive(false);
        });
    }
}
